package com.neuedu.web.utils;

import com.alibaba.fastjson2.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 金山
 * 项目：javaweb
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/11/1414:51
 */
public class JSONUtils {


    public static  void write(HttpServletResponse response , Object obj) throws IOException {

        // 告诉浏览器输出 html
        response.setContentType("application/json;charset=utf-8");

        // 解决跨域的问题
        // response.setHeader("Access-Control-Allow-Origin", "*");

        PrintWriter out =response.getWriter();
        out.write(JSONObject.toJSONString(obj));
        out.flush();
        out.close();
    }


}
